import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import {
    ValidatorMessageComponent,
    NoDataComponent,
    CardComponent,
    DatetimePickerComponent,
    SearchConditionComponent,
    CheckItemComponent
} from './components';
import {
    AttackChainDirective,
    EchartsPieDirective,
    EchartsLineDirective,
    GraphDirective
} from './directives';
import {
    TextEllipsisPipe,
    SafeHtmlPipe,
    AviodNullPipe,
    AvoidNullPipe,
    DatetimePipe,
    MappingPipe
} from './pipes';
import { NgZorroAntdModule, NZ_I18N, zh_CN } from 'ng-zorro-antd';

import { IsopCommonUiModule } from 'isop-common-ui';

/**
 * 我们添加SharedModule来存放这些公共组件、指令和管道，并且共享给那些需要它们的模块。
 * 很多组件同时用到了来自 CommonModule 的 NgIf 和 NgFor 指令，
 * 以及来自 FormsModule 的 [(ngModel)] 指令。
 * 通过让 SharedModule 重新导出 CommonModule 和 FormsModule 模块，我们可以消除这种重复。
 * SharedModule 本身所声明的组件没绑定过 [(ngModel)] ，那么，严格来说 SharedModule 并不需要导入 FormsModule 。
 * 这时 SharedModule 仍然可以导出 FormsModule
 */
const APP_MODULES = [CommonModule, FormsModule, ReactiveFormsModule, NgZorroAntdModule, RouterModule, IsopCommonUiModule];

const APP_COMPONENTS = [
    ValidatorMessageComponent,
    NoDataComponent,
    CardComponent,
    SearchConditionComponent,
    DatetimePickerComponent,
    CheckItemComponent
];

const APP_DIRECTIVES = [AttackChainDirective, EchartsPieDirective, EchartsLineDirective, GraphDirective];

const APP_PIPES = [TextEllipsisPipe, SafeHtmlPipe, AviodNullPipe,AvoidNullPipe, DatetimePipe, MappingPipe];
@NgModule({
    declarations: [
        ...APP_COMPONENTS,
        ...APP_DIRECTIVES,
        ...APP_PIPES
    ],
    imports: [
        ...APP_MODULES
    ],
    exports: [
        ...APP_MODULES,
        ...APP_COMPONENTS,
        ...APP_DIRECTIVES,
        ...APP_PIPES
    ],
    providers: [{ provide: NZ_I18N, useValue: zh_CN }]
})
export class SharedModule {
}
